package com.noname.lib_base_java.util;

import android.content.Context;
import android.content.res.AssetManager;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

/**
 * Author: Lmoumou
 * Date: 2018-09-27 15:18
 * 文件名: AssetsUtil
 * 描述:获取Asset文件夹内的文件
 */
public class AssetsUtil {
    public static String getJsonStr(String fileName, Context context) {
        StringBuilder stringBuilder = new StringBuilder();
        try {
            AssetManager assetManager = context.getAssets();
            BufferedReader bf = new BufferedReader(new InputStreamReader(assetManager.open(fileName)));
            String line;
            do {

                line = bf.readLine();
                stringBuilder.append(line);

            } while (line != null);

        } catch (IOException e) {
            e.printStackTrace();
        }
        return stringBuilder.toString();
    }
}
